/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DCSProjectPropertiesPanel.java
 *
 * Created on 2009-01-17, 00:57:11
 */

package pl.put.dcs_modeler.project.projectPropertiesExtensions.dcsProjectProperties;

import javax.swing.JFileChooser;
import org.netbeans.api.project.Project;

/**
 *
 * @author LukaszR
 */
public class DCSProjectPropertiesPanel extends javax.swing.JPanel {

    /** Creates new form DCSProjectPropertiesPanel */
    public DCSProjectPropertiesPanel( String path )
    {
        initComponents();
        setServerPath( path );
    }

    public String getServerPath()
    {
        return serverDirJTxt.getText();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        serverDirJTxt = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        jLabel1.setText(org.openide.util.NbBundle.getMessage(DCSProjectPropertiesPanel.class, "DCSProjectPropertiesPanel.jLabel1.text")); // NOI18N

        serverDirJTxt.setText(org.openide.util.NbBundle.getMessage(DCSProjectPropertiesPanel.class, "DCSProjectPropertiesPanel.serverDirJTxt.text")); // NOI18N

        jLabel2.setText(org.openide.util.NbBundle.getMessage(DCSProjectPropertiesPanel.class, "DCSProjectPropertiesPanel.jLabel2.text")); // NOI18N

        jButton1.setText(org.openide.util.NbBundle.getMessage(DCSProjectPropertiesPanel.class, "DCSProjectPropertiesPanel.jButton1.text")); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(serverDirJTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)
                .addGap(20, 20, 20))
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel2)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addGap(35, 35, 35)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(serverDirJTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(291, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed
    {//GEN-HEADEREND:event_jButton1ActionPerformed
        JFileChooser file = new JFileChooser();
        file.setDialogType( JFileChooser.OPEN_DIALOG );
        file.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
        int retVal = file.showOpenDialog( this );
        if ( retVal == JFileChooser.APPROVE_OPTION )
        {
            serverDirJTxt.setText( file.getSelectedFile().getPath() );
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    public void setServerPath( String path )
    {
        serverDirJTxt.setText( path );
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTextField serverDirJTxt;
    // End of variables declaration//GEN-END:variables

}
